#pragma once

#include "cybertron/bridge/CybertronBridgeTaskBase.hpp"
#include "cybertron/network/CybertronAsyncConn.hpp"

#include "SimulinkDevConfig.hpp"
#include "nlohmann/json.hpp"

typedef struct engine Engine;

CYBERTRON_BEGIN

class TaskSimulinkDev : public CybertronBridgeTaskBase
{
public:
	TaskSimulinkDev();
	~TaskSimulinkDev();

	bool onStart() override;
	uint16_t onFrame(uint64_t) override;
	void onEnd() override;

private:
	int setupSimulinkProject();
	std::string getMatlabExe();
	bool runMatlab();
	std::vector<string> transformNumToString(const int pose[], const int size);
	void addSubsystem(Engine* eg, const int vertices[], const std::string& name);
	void addSystemInput(Engine* eg, const int vertices[], const std::string& name);
	void setSensorPos(Engine* eg, const std::string& idx);
	void addSensors(Engine* eg, const int vertices[], const int index, const std::string& name, const int* params, const int paramNum);
	void addLines(Engine* eg, const std::string& startblock, const std::string& endblock, int startIdx, int endIdx );
	void addBlock(Engine* eg,const std::string& userblock, const int startPose[],const int distPixel);
    std::string mSimOneModuleRoot;
};

CYBERTRON_END
